package com.xuecheng.manage_course.controller;

import com.xuecheng.api.course.CourseMarketControllerApi;
import com.xuecheng.framework.domain.course.CourseMarket;
import com.xuecheng.framework.model.response.ResponseResult;
import com.xuecheng.manage_course.service.CourseMarketService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/course/market")
public class CourseMarketController implements CourseMarketControllerApi {

    @Resource
    CourseMarketService courseMarketService;

    /**
     * 根据课程id查询课程营销信息
     *
     * @param courseId 课程id
     * @return 查询课程营销信息
     */
    @Override
    @GetMapping("/get/{courseId}")
    public CourseMarket getCourseMarketById(@PathVariable("courseId") String courseId) {
        return courseMarketService.getCourseMarketById(courseId);
    }

    /**
     * 根据课程id更新课程信息
     *
     * @param id           课程id
     * @param courseMarket 课程实体类
     * @return 添加是否成功
     */
    @Override
    @PutMapping("/put/{id}")
    public ResponseResult updateCourseMarket(@PathVariable("id") String id, @RequestBody CourseMarket courseMarket) {
        return courseMarketService.updateCourseMarket(id, courseMarket);
    }
}
